package com.hz.sys.utils;

import com.alibaba.fastjson.JSON;

import java.io.Serializable;

/**
 * @author mcz
 * @Date 2018/10/23 11:53
 * @Description 自定义返回结果状态
 * @Version 1.0
 */
public final class ResponseUtils implements Serializable {
    private static final long serialVersionUID = 7366608027686369157L;
    private boolean resultFlag;
    //返回结果码   0:成功 1:失败
    private String responseCode;
    //返回结果描述
    private String responseDesc;
    //返回结果描述
    private String responseOptDesc;
    //返回数据集
    private Object responseData;
    private String result;

    public ResponseUtils() {
    }

    public String successJSON(ResponseUtils response){
        response.setResponseCode("0");
        response.setResultFlag(true);
        return JSON.toJSONString(response);
    }

    public String failJSON(ResponseUtils response){
        response.setResponseCode("1");
        response.setResultFlag(false);
        return JSON.toJSONString(response);
    }



    public ResponseUtils(String responseCode, String responseDesc) {
        this.responseCode = responseCode;
        this.responseDesc = responseDesc;
    }

    public ResponseUtils(String responseCode, String responseDesc, Object responseData) {
        this.responseCode = responseCode;
        this.responseDesc = responseDesc;
        this.responseData = responseData;
    }

    public Object getResponseData() {
        return responseData;
    }

    public void setResponseData(Object responseData) {
        this.responseData = responseData;
    }

    public String getResponseCode() {
        return responseCode;
    }

    public void setResponseCode(String responseCode) {
        this.responseCode = responseCode;
    }

    public String getResponseDesc() {
        return responseDesc;
    }

    public void setResponseDesc(String responseDesc) {
        this.responseDesc = responseDesc;
    }

    public ResponseUtils(String responseCode, String responseDesc, String responseOptDesc, Object responseData) {
        this.responseCode = responseCode;
        this.responseDesc = responseDesc;
        this.responseOptDesc = responseOptDesc;
        this.responseData = responseData;
    }

    public String getResponseOptDesc() {
        return responseOptDesc;
    }

    public void setResponseOptDesc(String responseOptDesc) {
        this.responseOptDesc = responseOptDesc;
    }

    public ResponseUtils(String responseCode, String responseDesc, String responseOptDesc, Object responseData, String result) {
        this.responseCode = responseCode;
        this.responseDesc = responseDesc;
        this.responseOptDesc = responseOptDesc;
        this.responseData = responseData;
        this.result = result;
    }

    public String getResult() {
        return result;
    }

    public void setResult(String result) {
        this.result = result;
    }

    public boolean isResultFlag() {
        return resultFlag;
    }

    public void setResultFlag(boolean resultFlag) {
        this.resultFlag = resultFlag;
    }
}
